A. Field of the Invention
The present invention relates generally to a graphics system for a personal computer. More particularly, the present invention relates to rendering polygons in a pixel grid. Still more particularly, the present invention relates to an improved method of applying texture to polygons.
B. Background of the Invention
Sophisticated graphics packages have been used for some time in expensive computer aided drafting, design and simulation systems. Increased capabilities of graphic controllers and display systems, combined with standardized graphics languages, have made complex graphics functions available in even the most routine applications. For example, word processors, spread sheets and desktop publishing packages now include relatively sophisticated graphics capabilities. Three-dimensional (3D) displays have become common in games, animation, and multimedia communication and drawing packages.
The availability of sophisticated graphics in PC's has driven a demand for even greater graphic capabilities. To obtain these capabilities, graphic systems must be capable of performing more sophisticated functions in less time to process greater amounts of graphical data required by modern software applications. In particular, there is a continuing need for improvements in software algorithms and hardware implementations to draw three=dimensional objects using full color, shading, texture mapping, and transparency blending.
The development of raster display systems has dramatically reduced the overall cost and increased the capabilities of graphic systems. In a raster display system, a set of orthogonal or horizontal scan lines, each comprising a row of pixels, forms an array or grid of pixels to represent the entire screen area. The screen preferably comprises a cathode ray tube (CRT), LCD display, or the like, capable of scanning the entire pixel grid at a relatively high rate to reduce flicker. The pixel data preferably is stored in a frame buffer comprising dynamic random access memories (DRAM's), or more preferably video RAMs (VRAM's), where each pixel is represented by one or more bits depending upon the desired resolution. In many graphics systems, for example, each pixel is drawn or "rendered" with 24 bits of color information (8 bits for red, 8 bits for green, 8 bits for blue). Typical display systems are capable of drawing screens with multiple colors at a variety of screen resolutions, including resolutions of 640 pixels.times.480 pixels, 800.times.600, 1024.times.768, 1280.times.1024, or even higher pixel value combinations, depending upon the software drivers and the hardware used.
Typically, a video controller scans and converts the pixel data in the frame buffer to provide control signals for the screen system. In particular, the video controller renders the screen pixels, typically from the top of the screen to the bottom and from left to right, converting pixel data into color intensity values each pixel. In a color graphics system using a CRT, three separate beams are controlled for each of the primary colors, where the intensity of each of the beams is determined by the pixel value corresponding to the respective colors. A similar system is used for LCD displays.
Other improvements have been made in the hardware realm. Graphics processors and accelerators are available with software drivers that interface the host central processing unit (CPU) to the graphics processor. In general, the software driver receives information for drawing objects on the screen, calculates certain basic parameters associated with the objects and provides these to the graphics processor. The software driver then sends a command for the graphics processor to draw the object into the frame buffer. A graphics processor may use interpolation techniques in which the fundamental information for the object to be drawn comprises a set of initial and incremental parameters. As explained below, the graphics processor loads or otherwise receives the initial parameters for rendering a first pixel, and then interpolates the remaining pixels in an object by using the incremented parameters until the object is complete.
An exemplary interpolation method for drawing a typical polygon is shown in FIG. 1 in which polygon 30 represents a wall extending from the foreground 34 to the background 36. Polygon 30 can be subdivided into two triangles 32 and 40. In general, however, a polygon is subdivided into as many triangles as are necessary to represent the polygon. For example, ten thousand triangles or more may be required to create a realistic looking image of a human face. Graphics objects typically are represented with a collection of triangles because triangles are simple geometric shapes that can be characterized with relatively few values.
Referring still to FIG. 1, each triangle 32, 40 may be drawn in two portions, such as portions 47, 49 of triangle 40. To render triangle 40, for example, a software driver receives vertex information (including x,y coordinates of each vertex 41, 42, 43) and identifies a main slope line 45 extending the vertical length (in the y direction) of triangle 40 between vertices 41 and 43. The other two sides 51, 53 of triangle 40 are referred to as opposite slopes. The polygon 40 is interpolated using orthogonal (ORTHO) horizontal scan lines of pixels that extend from the main slope 45 to the opposite edges 51, 53. ORTHO Scan lines 63, 65, 67 represent the first three scan lines for triangle 40. The vertical or y parameter is used as a reference coordinate, so that the y pixel value is preferably incremented (or decremented depending on whether the triangle is rendered from top to bottom or bottom to top) by one for each scan line. A value for the main slope 45 is calculated as an initial condition and is used to compute the x coordinate of the first pixel in each scan line (i.e., the pixels on of the main slope). The software driver also determines initial and incremental width values for the scan lines and interpolates the width rather than edge walking the opposite slopes. The interpolated width value is loaded into a counter and decremented for each pixel in the current scan line. When the width counter becomes zero or otherwise reaches terminal count, the counter asserts a terminal count signal indicating that the scan line is complete.
Using such interpolation techniques, each triangle 32, 40 is drawn one row or horizontal scan line of pixels at a time. For each scan line of triangle 40 (such as scan lines 63, 65, 67), pixels are rendered from the main slope 45 to the opposite edges 51, 53. In the first scan line 63, vertex pixel 41 is rendered. In the second scan line 65, pixels 52 then 53 are rendered. In the third scan line 67, pixels 54, 55, 56 are rendered.
Graphics processors, such as the GD5464 manufactured by Cirrus Logic, are capable of applying texture to polygons through a process referred to as texture mapping. Texture mapping techniques generally apply a bitmapped texture image to a polygon on the screen. A texture map typically is a two dimensional array of texture elements ("texels") that define a texture such as a brick, a carpet design, the grain of wood or any other texture that might be applied to an object on a computer screen. Referring now to FIG. 2, an exemplary brick texture 44 is applied to polygon 30 to create the appearance of a brick wall. The brick texture 44 is represented by a texture map. The texture map used in FIG. 2 may represent only a single brick which is applied repeatedly to polygon 30 to cover the entire polygon with bricks.
Using standard techniques, the texture map associated with the texture 44 is applied to polygon 30 in such a way to give the appearance of perspective to the brick wall of FIG. 2. To further improve upon the realism of the brick wall, the bricks that are close to the viewer (brick 59 for example) preferably are shown with greater detail than the bricks in the distance (brick 61). The detail includes the imperfections in the exposed surface of brick 59, the mortar between bricks and any other detailed desired. Such detail normally could not be seen in the distant brick 61. Accordingly, the graphics processor uses different versions of the brick texture map to account for differences in the level of detail in an object drawn with perspective. Each version is itself a texture map that includes a predetermined amount of detail. The texture map used to render brick 61 would not include the imperfections and other detail that could be seen in brick 59. Thus, a particular texture, such as the brick of FIG. 2, may include two or more texture maps representing the brick with varying levels of detail. MIP (multim in parvum) mapping is a technique by which the graphics processor selects a texture map with an appropriate level of detail to render a polygon. Using MIP mapping, the graphics processor switches between the various level of detail texture maps as the polygon is rendered.
The desire for sophisticated and realistic computer graphics requires the graphics hardware and software to deliver high performance. Performance becomes especially critical for computer games which typically include moving objects. Standard MIP mapping techniques for switching between various level of detail texture maps generally include computationally intensive operations and require numerous memory accesses that impair a graphics system's ability to deliver detailed, realistic, three-dimensional moving images.
Many graphics systems do not permit switching between level of detail texture maps while rendering the pixels in a screen object drawn with perspective. To apply varying level of detail texture maps to a screen object, such systems divide screen objects into numerous, smaller triangles so that a single level of detail texture map can be applied to each triangle. This type of system requires objects to be represented with more triangles than would otherwise be necessary placing increased demands on texture map memory storage.
Accordingly, it would be desirable to provide a graphics system that includes a MIP mapping scheme that requires relatively few memory accesses and computations. It would also be desirable to provide a system that permits switching between different levels of detail while rendering a single polygon. Such a system would provide increased performance while also providing high quality graphics.